package com.company;

import com.util.Util;

import java.awt.*;

import static com.company.RB.getColor;

/**
 * 监控器
 */
class Monitor {

    //等待上钩
    boolean waitBite(int x, int y){
        int i = 0;
        while (true) {
            Color color = getColor(x, y);
            if( firstTest(color) && secondTest(color)){
                return true;
            }

            Util.sleep(300L);

            i++;
            if (i % 3 == 0){
                System.out.print(".");
            }
        }
    }

    private boolean firstTest(Color color){
        return color.getRed() < 15;
    }

    private boolean secondTest(Color color){
        int r = color.getRed();
        int g = color.getGreen();
        int b = color.getBlue();
        return (r+g+b<=82) && (b-g<=24) && (g-r<=7);
    }

}
